from selenium import webdriver
from selenium.webdriver.common.by import By
import time

url = 'http://www.baidu.com'
driver = webdriver.Edge()
driver.get(url)
print(driver.get_cookies())
# 传统方法
# cookies = {}
# for data in driver.get_cookies():
#     cookies[data['name']] = data['value']
# 字典推导式
cookies = {data['name']: data['value'] for data in driver.get_cookies()}
print(cookies)